package example.collections;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Created by lenovo on 2016/11/7 0007.
 * 用 collections 类 collections.shuffle() 方法来打乱集合元素的顺序
 */
public class Shuffle {
    public static void main(String[] args) {
        List<Integer> list = new ArrayList<Integer>();
        for (int i = 0; i < 10; i++){
            list.add(i);//因为java目前版本早就可以自动拆装箱，不需要将i转化为integer
        }

        System.out.println("打乱前:");
        System.out.println(list);

        for (int i = 1; i < 6; i++) {
            System.out.println("第" + i + "次打乱：");
            //集合打乱，随机?
            Collections.shuffle(list);
            System.out.println(list);
        }
    }
}
